#ifndef		__MSG_FACTORY__BYMAP__
#define		__MSG_FACTORY__BYMAP__

#include "MsgFactoryIf.h"

typedef IMsg* (*MessageFunctor)();

//
//	Message Factory
//

class TCOM_API  MsgFactoryByMap: public IMsgFactory
{
public:
	MsgFactoryByMap();
	virtual ~MsgFactoryByMap();


	//
	//	create a message base on message category and message id
	//
	virtual	IMsg*	createMsg(int nMsgCate, int nMsgID);


	template<class Msg>
	static IMsg*	create()
	{
		return new Msg;
	}

	void registerMsg(int nCate, int nID, MessageFunctor func);
protected:
	typedef	stdext::hash_map<int, MessageFunctor>	MessageCreatorMap;
	MessageCreatorMap m_theMap;
};

#endif

